package com.pandas.community.Utils;

public class RedisKeyUtil {

    private static final String SPLIT=":";
    private static final String PREFIX_ENTITY_LIKE = "like:entity";
    private static final String PREFIX_USER_LIKE = "like:user";
    private static final String FOLLOWEE = "followee";
    private static final String FOLLOWER = "follower";
    private static final String PREFIX_KAPTCHA = "kaptcha";
    private static final String PREFIX_LOGIN_TICKET = "login:ticket";
    private static final String PREFIX_USER = "user";

    //某个实体的赞
    // like:entity:entityType:entityId -> set(userid)
    public static String getEntityLikeKey(int entityType, int entityId){
        return PREFIX_ENTITY_LIKE + SPLIT + entityType + SPLIT + entityId;
    }

    //某个用户收到的赞
    // liker:user  -> value
    public static String getUserLikeKey(int userid){
        return PREFIX_USER_LIKE + SPLIT + userid;
    }

    // 关注的人
    // followee:userid:entityType -> zset(entityId, now)
    public static String getFolloweeKey(int userid, int entityType){
        return FOLLOWEE + SPLIT + userid + SPLIT + entityType;
    }

    // 跟随者
    // follower:entityType:entityId -> zset(userid, now)
    public static String getFollowerKey(int entityType, int entityId){
        return FOLLOWER + SPLIT + entityType + SPLIT + entityId;
    }

    //登录验证码
    // 未访问登录页面设置一个字符串
    public static String getKaptchaKey(String owner){
        return PREFIX_KAPTCHA + SPLIT + owner;
    }

    // 登录凭证
    public static String getLoginTicketKey(String ticket){
        return PREFIX_LOGIN_TICKET + SPLIT + ticket;
    }

    //用户
    public static String getUserKey(int userid){
        return PREFIX_USER + SPLIT + userid;
    }

}
